/*
 * Language.java
 */

package dbindex;


/** List of languages<br>
 * 0 - English
 * 1 - Russian
 *
 * See more in: Effective Java. Programming language Guide. J.Bloch. 
 */
public class Language {
    
    private final int       lang_id;
    private final String    lang_str;
    
    private Language(int lang_id,String lang_str) {
        this.lang_id  = lang_id; 
        this.lang_str = lang_str; 
    }
    
    public String toString() { return lang_str; }
    public int    toInt()    { return lang_id;  }
    
    /** English language */
    public static final Language ENGLISH        = new Language(0, "English");
    
    /** Russian language */
    public static final Language RUSSIAN        = new Language(1, "Russian");
    
    /** Gets Language by number */
    public static Language get(int lang_id) throws NullPointerException
    {
        if(lang_id == ENGLISH.toInt()) {
            return ENGLISH;
        } else if(lang_id == RUSSIAN.toInt()) {
            return RUSSIAN;
        } else {
            throw new NullPointerException("Null Language");
        }
    }
}
